from base.base import Base
from selenium.webdriver.common.by import  By
from time import sleep



class GeneralProblemPage(Base):
    #定位商品管理
    goodsmanager = (By.XPATH,'//span[text()="商场管理"]')
    def clickgoodsmanager(self):
        self.loc_ele(self.goodsmanager).click()

    generalproblem = (By.XPATH, '//span[text()="通用问题"]')
    def clickgeneralproblem(self):
        self.loc_ele(self.generalproblem).click()

    #定位添加问题按钮
    addgeneralproblembutton = (By.CSS_SELECTOR,'#app > div > div.main-container > section > div > div.filter-container > button:nth-child(3)')
    def clickaddproblembutton(self):
        self.loc_ele(self.addgeneralproblembutton).click()

    #定位问题输入框
    probleminput = (By.CLASS_NAME,"el-input__inner")
    def inputproblemcontent(self,c):
       eles =  self.loc_eles(self.probleminput)
       ele = eles[3]
       ele.send_keys(c)

    #定位问题回复框
    inputreplycontent = (By.CLASS_NAME,"el-textarea__inner")
    def inputreplycontentbusiness(self,c):
        ele=  self.loc_ele(self.inputreplycontent)
        ele.send_keys(c)

    #定位确定按钮
    ensurebutton = (By.XPATH,'/html/body/div[1]/div/div[2]/section/div/div[4]/div/div[3]/div/button[2]/span')
    def clickensurebutton(self):
        self.loc_ele(self.ensurebutton).click()

    #断言用到的元素
    dy = (By.XPATH,'//table[@class="el-table__body"]/tbody/tr[1]/td[2]/div')
    def getdycontent(self):
        return self.loc_ele(self.dy).text


    #操作业务的方法
    def addproblembussiness(self,q,r):
        self.clickgoodsmanager()
        sleep(1)
        self.clickgeneralproblem()
        sleep(1)
        self.clickaddproblembutton()
        sleep(1)
        self.inputproblemcontent(q)
        self.inputreplycontentbusiness(r)
        sleep(2)
        self.clickensurebutton()
        sleep(3)



